<template>
  <div class="student">
      <h2>学生姓名：{{name}}</h2>
      <h2>学生性别：{{sex}}</h2>
      <button @click="sendStudentName">把学生名给school</button>
  </div>
</template>

<script>

import pubsub from 'pubsub-js'

export default {



  // eslint-disable-next-line vue/multi-word-component-names
  name: "Student",
  data(){
    return{
      sex:'男',
      name:'张三',

    }
  },
  methods:{
    sendStudentName() {
      //给傀儡触发事件
      // this.$bus.$emit('hello',666)
      //发布消息
      pubsub.publish('hello',666)
    }
  }




}
</script>

<style scoped lang="less">
    .student{
      background-color: orange;
      padding: 10px;
    }
</style>